<?php

/**
 * 标签
 *
 * Created by PhpStorm.
 * User: evan
 * Date: 16/9/7
 * Time: 上午7:31
 */
class Tag extends MY_Api_Controller
{
    /**
     * 获取标签
     */
    public function get()
    {
        $by_module = (int)$this->input->get_post('by_module');
        $limit     = (int)$this->input->get_post('limit');


        $this->load->service('common/service_common_tag');
        $data = $this->service_common_tag->get($by_module, $limit);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 添加标签
     */
    public function add()
    {
        $name = trim($this->input->get_post('name'));


        $this->load->service('common/service_common_tag');
        $data = $this->service_common_tag->add($name);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     *  建立/取消关联
     */
    public function build()
    {
        $tid       = (int)$this->input->get_post('tid');
        $bid       = (int)$this->input->get_post('bid');
        $by_module = (int)$this->input->get_post('by_module');


        $this->load->service('common/service_common_tag');
        $data = $this->service_common_tag->build($tid, $bid, $by_module);


        $this->json_output($data['data'], $data['status']);
    }
}